package lab3;

import java.util.Random;

public class NumberGuess {
	private int number;
	private int numGuess;
	private boolean success;
	private String hind;

	public NumberGuess() {
		init();
	}

	private void init() {
		number = new Random().nextInt(100) + 1;
		numGuess = 0;
		success = false;
	}

	public void guess(String guess) {
		numGuess++;

		int answer;
		try {
			answer = Integer.parseInt(guess);
		} catch (NumberFormatException e) {
			answer = -1;
		}

		if (answer == -1) {
			hind = "a number next time";
		} else if (answer > number) {
			hind = "lower";
		} else if (answer < number) {
			hind = "higher";
		} else {
			success = true;
		}
	}

	public boolean isSuccess() {
		return this.success;
	}

	public String getHind() {
		return this.hind;
	}

	public int getNumGuess() {
		return this.numGuess;
	}

}
